guys, i have questions. How do i get filenames from a folder using typescript? I trying next way:
import * as fs from 'fs';
class HTML_Element {
public html_element: HTMLElement;
constructor(html_string: string) {
this.html_element = new HTMLElement();
this.html_element.className = "gallery_item";
this.html_element.innerHTML = html_string;
}
}
const html_div: HTML_Element = new HTML_Element("FSDfdsfsd");
const list_image: any = fs.readdirSync('../image/')
console.log(list_image)
4.I write command in terminal "tsc app.ts" and get "app.js"
"use strict";
exports.__esModule = true;
var fs = require("fs");
var HTML_Element = /** @class */ (function () {
function HTML_Element(html_string) {
this.html_element = new HTMLElement();
this.html_element.className = "gallery_item";
this.html_element.innerHTML = html_string;
}
return HTML_Element;
}());
var html_div = new HTML_Element("<div>FSDfdsfsd</div>");
var list_image = fs.readdirSync('../image/');
console.log(list_image);
5.I get error in the browser: Uncaught ReferenceError: require is not defined